<?php
//
// 晒单
//
class Controller_Admin_Show extends Controller_Form
{
    public function __construct ($req, $res)
    {
        $this->_form_type = 'show';
        parent::__construct($req, $res);

        $this->_list_where = array();
        $this->_list_pagesize = 20;
        $this->_no_buttons    = TRUE;

        $this->_sort_extra_columns = array(
            array('changed', DB::expr('curdate()')),
        );

        $this->_shopId = App_Shop_Manager::currentShopId();
        if ($this->_shopId > 0)
            $this->_list_where[] = array('o.shopId', '=', $this->_shopId);
    }

	//默认首页
    public function action_index ()
    {
        $this->action_list();
    }

    public function action_create ()
    {
        return;
    }

    public function action_update ($nid)
    {
        return;
    }

	// 详情
	//$nid int 商铺ID
    public function action_detail ($nid)
    {
        $data = Form_Data::detail($this->_form_type, $nid); 

        $data['userName'] = User::getUserFromUid($data['uid'])->getUserName();
        $data['images']   = explode('|', $data['images']);
        $data['created']  = date("Y-m-d H:i:s", $data['created']);
        $this->_form_data = $data;
        parent::action_detail($nid);
    }

    public function detail_filter_config_data (& $arr_config)
    {
        //
    }

	//重构数据
    private function rebuild_post_data (& $post)
    {
        //
    }

	// 列表数据改造
    public function list_filter_data (& $rows)
    {
        foreach ($rows as & $rs)
        {
            //
            $shopId = $rs['shopId'];
            $rs['shopId'] = App_Shop::name($shopId);
        }
    }

    public function list_get_data ($offset, $limit)
    {
        $show = new App_Show;
        $xs   = $show->infoList($offset, $limit, $this->_list_where);
        return $xs;
    }


	//操作菜单
    public function actions_by_list_row (& $row, & $menus)
    {
        unset($menus[1]);
        //array_unshift($menus, '<a href="/
    }
}
